package com.fx.algorithm.first;

import java.util.StringJoiner;

/**
 * @author fx
 */
public class ListNode {

    int val;
     ListNode next;
     ListNode() {}
     ListNode(int val) { this.val = val; }
     ListNode(int val, ListNode next) { this.val = val; this.next = next; }

    @Override
    public String toString() {
        StringJoiner joiner = new StringJoiner(",", "[", "]");
        ListNode node = this;
        while (node != null) {
            joiner.add(String.valueOf(node.val));
            node = node.next;
        }
        return joiner.toString();
    }

}
